using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Newtonsoft.Json.Linq;
using Parker.Business;
using WineCellar.Business.Entities;
using WineCellar.Business.ServiceInterfaces;
using WineCellar.Core.Interfaces;
using WineCellar.Web.Controllers;

namespace Parker.Web.Controllers
{
    public class ParkerWineController :WineController<ParkerWine>
    {
        public ParkerWineController(IEntityService<ParkerWine> wineService, IUserService userService, IEntityService<Region> regionService) : base(wineService, userService, regionService)
        {
        }
        
        protected override JObject GetJson(IEnumerable<ParkerWine> wines, int totalCount)
        {
            return new JObject(
                new JProperty("totalcount", totalCount),
                new JProperty("root",
                              new JArray(
                                  from c in wines
                                  select new JObject(
                                      new JProperty("Id", c.Id.ToString()),
                                      new JProperty("Name", c.Name),
                                      new JProperty("Appelation", c.Appelation),
                                      new JProperty("Producer", c.Producer),
                                      new JProperty("Score", c.Score)))));
        }
    }
}